import 'package:get/get.dart';
import 'package:hygf/http/file_transfer/down_cap.dart';

import '../../../../bean/CustomerList.dart';
import '../../../../http/DioClient.dart';
import '../../../../view/image_picker_widget.dart';
import '../CustomerDetailPage.dart';
import 'state.dart';

class CheckAcceptLogic extends GetxController {
  final CheckAcceptState state = CheckAcceptState();

   @override
  void onReady() {
    super.onReady();
  }

  Future<void> initImgUrl() async {
    if((state.acceptance.reportFile??"").isNotEmpty){
      List<ImagePickerData> reportFileData = await DioClient().requestImgUrl(state.acceptance.reportFile);
      state.reportFileController.addImages(reportFileData);
    }
    if((state.acceptance.other??"").isNotEmpty){
      List<ImagePickerData> otherData = await DioClient().requestImgUrl(state.acceptance.other);
      state.otherController.addImages(otherData);
    }
    update();
  }

  Future<void> setData(Acceptance? tempData) async {
    if (tempData != null) {
      state.acceptance = tempData;
      await initImgUrl();
      Get.find<RefreshTabLogic>(tag: "6").refreshTabBar();
    }
  }
}
